<template>
  <div class="social-signup-container">
    <div class="other-way">
        <hr>
        <span class="info">或使用以下帐号登录</span>
    </div>
    <div class="auth-link">
      <div class="login-btn qq" @click="socialiteLogin('qq')">
        <i class="el-icon-yuethink-qq"></i>
      </div>
      <div class="login-btn weibo" @click="socialiteLogin('weibo')">
         <i class="el-icon-yuethink-weibo"></i>
      </div>
      <div class="login-btn wechat" @click="socialiteLogin('wechat')">
         <i class="el-icon-yuethink-yingdaicon04"></i>
      </div>
    </div>
  </div>
</template>
<script>
  import {openWindow} from '@/utils/helpers'
  import {SERVER_URL} from '@/utils/config'
  export default{
    data () {
      return {
      }
    },
    methods: {
      socialiteLogin (driver) {
        let url = SERVER_URL + '/socialite/' + driver
        openWindow(url, '_blank', 540, 540)
      }
    },
    mounted () {
      if (this.$route.query.access_token) {
        if (window.opener && !window.opener.closed) {
          window.opener.location.href = window.location.href
          window.opener.location.reload()
          window.close()
        } else {
          this.$store.commit('SET_TOKEN', this.$route.query.access_token)
          let url = this.$route.query.redirect ? this.$route.query.redirect : '/'
          this.$router.push(url)
        }
      }
    }
  }
</script>
<style lang="scss" scoped>
  .other-way {
    position: relative;
    hr {
      height: 1px;
      margin: 30px 0 20px;
      border: 0;
      background-color: #e4e7ed;
      display: block;
    }
    .info {
      font-size: 14px;
      line-height: 1;
      position: absolute;
      top: -6px;
      left: 50%;
      padding: 0 10px;
      transform: translate(-50%,0);
      color: #9ba3af;
      background-color: #fff;
    }
  }
  .auth-link {
    font-size: 20px;
    text-align: center;
    margin-top: 15px;
    margin-bottom: 15px;
    .login-btn {
      display: inline-block;
      width: 30px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      border-radius: 30px;
      margin-bottom: 20px;
      background-color: #b5b9bc;
      margin: 0 15px;
      &:hover {
        background-color: #FF4949;
      }
      i {
        color: #fff;
        display: inline-block;
        padding-top: -20px;
      }
    }
    .weibo {
    }
  }
</style>